const { build, pause, concat } = require('./build');

var files = [
  "stdio/stdio",
  "stdio/__vfscanf",
  "stdio/vfprintf", "stdio/vfscanf",
  "stdio/fprintf",
  "stdio/vsprintf",
  "stdio/vsnprintf",
  "stdio/snprintf",
  "stdio/sprintf",
  "stdio/printf", "stdio/scanf",
  "stdio/vprintf", "stdio/vscanf",
  "stdio/puts",
  "stdio/fputs",
  "stdio/putchar",
  "stdio/ungetc",
  "stdio/printf_fp",
  "stdio/internals",
  "stdio/fflush",
  "stdio/fwrite",
  "stdio/ferror",
  "stdio/reg-printf",
  "stdio/_itoa",
  "stdio/feof",
  "stdio/mp_clz_tab",


  "stdlib/__random",
  "stdlib/rand",
  "stdlib/srand",
  "stdlib/mblen",
  "stdlib/mbtowc",
  "stdlib/strtol",
  "stdlib/strtod",
  "string/string",
  "string/strdup",

  "locale/C-ctype",
  "locale/C-ctype_ct",
  "locale/C-ctype_mb",
  "locale/C-numeric",
  "ctype/ctype-info",

  "errlist",

  "math/__scalb",

  "sysdeps/generic/add_n",
  "sysdeps/generic/sub_n",
  "sysdeps/generic/mul_1",
  "sysdeps/generic/lshift",
  "sysdeps/generic/rshift",
  "sysdeps/generic/divmod",
  "sysdeps/generic/divmod_1",
  "sysdeps/generic/submul_1",
  "sysdeps/generic/cmp",
  "sysdeps/generic/strcpy",
  "sysdeps/generic/strcmp",
  "sysdeps/generic/memcpy",
  "sysdeps/generic/memcmp",
  "sysdeps/generic/memset",
  "sysdeps/generic/floor",
  "sysdeps/generic/ceil",
  "sysdeps/generic/tan",
  "sysdeps/generic/log10",
  "sysdeps/generic/exp__E",
  
  "sysdeps/generic/asin",
  "sysdeps/generic/acos",
  "sysdeps/generic/atan",
  "sysdeps/generic/atan2",
  "sysdeps/generic/pow",
  "sysdeps/generic/log",
  "sysdeps/generic/exp",
  "sysdeps/generic/frexp",
  "sysdeps/generic/fabs",
  "sysdeps/generic/ldexp",
  "sysdeps/generic/__copysign",
  "sysdeps/generic/sincos",
  "sysdeps/generic/memmove",
  "sysdeps/generic/wordcopy",
  "sysdeps/generic/fmod",
  "sysdeps/generic/strrchr",

  "sysdeps/ieee754/sqrt",
  "sysdeps/ieee754/__isnan",
  "sysdeps/ieee754/__isinf",
  "sysdeps/ieee754/__drem",
  "sysdeps/ieee754/__logb",
  "sysdeps/ieee754/dbl2mpn",

  "sysdeps/stub/stdio_init",
  "sysdeps/stub/sysd-stdio",

  "math/__finite",
  "math/finite",
  "math/isnan",
]

var proc = async () => {

  var hardFloat = process.argv[2] == "hardFloat";
  var cpp = false;
  var param = ["-I./glibc", "-D_LIBC"];

  var targets = [];
  for (var i = 0; i < files.length; i++) {
    var ret = await build("glibc/" + files[i], hardFloat, cpp, param);
    targets.push(ret);
  }

  concat(targets, "glibc.s");

  console.log("finish");
  //pause();
}
proc();

//setTimeout(() => { }, 100000);
